//
//  WBMTRightCell.m
//  WBMTwaimai
//
//  Created by WangBiao on 16/9/22.
//  Copyright © 2016年 lsrain. All rights reserved.
//

#import "WBMTRightCell.h"

@interface WBMTRightCell ()

@property (nonatomic, weak) UIImageView *iconImageView;
@property (nonatomic, weak) UILabel *nameLabel;
@property (nonatomic, weak) UILabel *monthSaleLabel;
@property (nonatomic, weak) UILabel *prasiseLabel;
@property (nonatomic, weak) UILabel *priceLabel;
@property (nonatomic, weak) UILabel *descLabel;
@end

@implementation WBMTRightCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setRightModel:(WBMTRightList *)rightModel{
    _rightModel = rightModel;
    self.nameLabel.text = rightModel.name;
    self.monthSaleLabel.text = rightModel.month_saled.description;
    self.priceLabel.text = rightModel.praise_num.description;
    self.descLabel.text = rightModel.desc;
}

#pragma make - 搭建界面
- (void)setupUI{
    
    //头像
    UIImageView *iconView = [[UIImageView alloc]init];
    iconView.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:iconView];
    
    [iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).mas_offset(15);
        make.top.mas_equalTo(10);
        make.size.mas_equalTo(CGSizeMake(50, 50));
    }];
    
    //菜名
    UILabel *nameLabel = [UILabel cz_labelWithText:@"" fontSize:13 color:[UIColor cz_colorWithHex:0x000000]];
    [self.contentView addSubview:nameLabel];
    
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(iconView.mas_right).mas_offset(10);
        make.top.equalTo(iconView);
    }];
    
    //月售
    UILabel *monthSaleLabel = [UILabel cz_labelWithText:@"" fontSize:11 color:[UIColor cz_colorWithHex:0x7e7e7e]];
    [self.contentView addSubview:monthSaleLabel];
    
    [monthSaleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(nameLabel);
        make.top.equalTo(nameLabel.mas_bottom).offset(2);
    }];
    
    //点赞图片
    UIImageView *prasiseImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"icon_food_count_bg"]];
    [self.contentView addSubview:prasiseImgView];
    
    [prasiseImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(monthSaleLabel.mas_right).mas_equalTo(3);
        make.top.equalTo(monthSaleLabel);
        make.size.mas_equalTo(CGSizeMake(11, 11));
    }];
    
    //点赞数
    UILabel *prasiseLabel = [UILabel cz_labelWithText:@"" fontSize:11 color:[UIColor cz_colorWithHex:0x7e7e7e]];
    [self.contentView addSubview:prasiseLabel];
    
    [prasiseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(prasiseImgView.mas_right).mas_equalTo(3);
        make.top.equalTo(prasiseImgView);
        make.height.mas_equalTo(11);
    }];

    
    //价格
    UILabel *priceLabel = [UILabel cz_labelWithText:@"" fontSize:14 color:[UIColor cz_colorWithHex:0xfa2a09]];
    [self.contentView addSubview:priceLabel];
    
    [priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(monthSaleLabel);
        make.bottom.equalTo(iconView.mas_bottom);
    }];
    
    //描述
    UILabel *descLabel = [UILabel cz_labelWithText:@"" fontSize:14 color:[UIColor cz_colorWithHex:0x848484]];
    [self.contentView addSubview:descLabel];
    
    [descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(iconView);
        make.height.mas_equalTo(11);
        make.bottom.equalTo(self.contentView.mas_bottom).mas_offset(-5);
    }];
    
    
    //赋值
    self.nameLabel = nameLabel;
    self.monthSaleLabel = monthSaleLabel;
    self.prasiseLabel = prasiseLabel;
    self.priceLabel = priceLabel;
    self.descLabel = descLabel;
}

@end
